﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A81静态成员和静态类
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine();
            //访问自己类的静态成员
            int sum = Program.Add(2, 3);
            Console.WriteLine(Program.x);
            //访问其他类的静态成员
            Console.WriteLine(MyClass.number);

            //非静态成员要先有对象才能调用
            MyClass mc1 = new MyClass();
            mc1.name = "张三";

            MyClass mc2 = new MyClass();
            mc2.name = "李四";
        }

        static int x = 345;
        static int Add(int a, int b)
        {
            return a + b;
        }
    }
}
